package zijin.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import zijin.service.HelloFeignFallbackService;
import zijin.service.HelloFeignService;

/**
 * @Auther: hejianding
 * @Date: 2021/3/12 16:00
 * @Version: 1.0
 */
@RestController
public class IndexController {
    @Autowired
    HelloFeignService helloFeignService;

/*  //手动在方法上进行熔断降级，时间要小于全局默认的时间才会生效
    @HystrixCommand(fallbackMethod = "getNameFallback", commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "4000")
    },
            threadPoolKey = "hystrixDemoThreadPool",
            threadPoolProperties = {
                    @HystrixProperty(name = "coreSize", value = "30"),
                    @HystrixProperty(name = "maxQueueSize", value = "10")
            })
*/
    @RequestMapping(value = "/hello" , method = RequestMethod.GET)
    public String hello(String name){
        return helloFeignService.hello(name);
    }

}
